core: Some tweaks to ls output
authorColin Walters <walters@verbum.org>
Mon, 28 Nov 2011 15:17:49 +0000 (10:17 -0500)
committerColin Walters <walters@verbum.org>
Mon, 28 Nov 2011 15:17:49 +0000 (10:17 -0500)
src/libostree/ostree-repo-file.c
src/ostree/ot-builtin-ls.c

index fd9b30fd1cfcb00c6c997d0c31304ab5c7b35443..11887f0d185299dc614500396c266623bbd4ade6 100644 (file)
@@ -194,8 +194,10 @@ do_resolve_commit (OstreeRepoFile  *self,
   root_metadata = NULL;
   self->tree_contents = root_contents;
   root_contents = NULL;
+  self->tree_contents_checksum = g_strdup (tree_contents_checksum);
   self->tree_metadata_checksum = g_strdup (tree_meta_checksum);
 
+  ret = TRUE;
  out:
   ot_clear_gvariant (&commit);
   ot_clear_gvariant (&root_metadata);
@@ -253,6 +255,8 @@ do_resolve_nonroot (OstreeRepoFile     *self,
       tree_contents = NULL;
       self->tree_metadata = tree_metadata;
       tree_metadata = NULL;
+      self->tree_contents_checksum = g_strdup (content_checksum);
+      self->tree_metadata_checksum = g_strdup (metadata_checksum);
     }
   else
     self->index = i;
@@ -377,7 +381,6 @@ _ostree_repo_file_tree_set_content_checksum (OstreeRepoFile  *self,
 const char *
 _ostree_repo_file_tree_get_content_checksum (OstreeRepoFile  *self)
 {
-  g_assert (self->parent == NULL);
   return self->tree_contents_checksum;
 }
 
index c3d92cdae331f892ac0beb527a536e6ed285f05d..7784b3a631b33559671eb751539a95e1e64cb3db 100644 (file)
@@ -45,12 +45,17 @@ print_one_file (GFile     *f,
   GString *buf = NULL;
   char type_c;
   guint32 mode;
+  guint32 type;
+
+  if (!_ostree_repo_file_ensure_resolved ((OstreeRepoFile*)f, NULL))
+    g_assert_not_reached ();
   
   buf = g_string_new ("");
 
   type_c = '?';
   mode = g_file_info_get_attribute_uint32 (file_info, "unix::mode");
-  switch (g_file_info_get_file_type (file_info))
+  type = g_file_info_get_file_type (file_info);
+  switch (type)
     {
     case G_FILE_TYPE_REGULAR:
       type_c = '-';
@@ -74,14 +79,18 @@ print_one_file (GFile     *f,
       break;
     }
   g_string_append_c (buf, type_c);
-  g_string_append_printf (buf, "0%03o %u %u %" G_GUINT64_FORMAT " ",
+  g_string_append_printf (buf, "0%04o %u %u %6" G_GUINT64_FORMAT " ",
                           mode & ~S_IFMT,
                           g_file_info_get_attribute_uint32 (file_info, "unix::uid"),
                           g_file_info_get_attribute_uint32 (file_info, "unix::gid"),
                           g_file_info_get_attribute_uint64 (file_info, "standard::size"));
   
   if (checksum)
-    g_string_append_printf (buf, "%s ", _ostree_repo_file_get_checksum ((OstreeRepoFile*)f));
+    {
+      if (type == G_FILE_TYPE_DIRECTORY)
+        g_string_append_printf (buf, "%s ", _ostree_repo_file_tree_get_content_checksum ((OstreeRepoFile*)f));
+      g_string_append_printf (buf, "%s ", _ostree_repo_file_get_checksum ((OstreeRepoFile*)f));
+    }
 
   if (xattrs)
     {
@@ -94,14 +103,14 @@ print_one_file (GFile     *f,
       formatted = g_variant_print (xattrs, TRUE);
       g_string_append (buf, "{ ");
       g_string_append (buf, formatted);
-      g_string_append (buf, "} ");
+      g_string_append (buf, " } ");
       g_free (formatted);
       g_variant_unref (xattrs);
     }
 
   g_string_append (buf, ot_gfile_get_path_cached (f));
 
-  if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_SYMBOLIC_LINK)
+  if (type == G_FILE_TYPE_SYMBOLIC_LINK)
     g_string_append_printf (buf, " -> %s", g_file_info_get_attribute_byte_string (file_info, "standard::symlink-target"));
       
   g_print ("%s\n", buf->str);